import request from '@/utils/request'

// 查询文章列表
export function listPosts(query) {
  return request({
    url: '/blog/posts/list',
    method: 'get',
    params: query
  })
}

// 新增
export function addPosts(data) {
  return request({
    url: '/blog/posts',
    method: 'post',
    data: data
  })
}

// 是否启用文章评论
export function changeIsComment(postsId, isComment) {
  const query = {
    postsId,
    isComment
  };
  return request({
    url: '/blog/posts/update/comment',
    method: 'put',
    params: query
  })
}

// 发布文章
export function releasePosts(postsId) {
  return request({
    url: '/blog/posts/release/' + postsId,
    method: 'put'
  })
}

// 删除文章
export function delPosts(postsId) {
  return request({
    url: '/blog/posts/' + postsId,
    method: 'delete'
  })
}

// 下架文章
export function offPosts(postsId) {
  return request({
    url: '/blog/posts/off/' + postsId,
    method: 'put'
  })
}

// 获取文章信息
export function getPosts(postsId) {
  return request({
    url: '/blog/posts/' + postsId,
    method: 'get'
  })
}

// 修改文章信息
export function updatePosts(data) {
  return request({
    url: '/blog/posts',
    method: 'put',
    data: data
  })
}
